﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ITAP.ShprossesBuilder.Modelling;
using ITAP.ShprossesBuilder.Modelling.Components.Actions;
using ITAP.ShprossesBuilder.Modelling.Components;
using ITAP.ShprossesBuilder.Editor;
using ITAP.ShprossesBuilder.Properties;

namespace ITAP.ShprossesBuilder.Operations
{
    public class OperationBreakSelectedShprossesToPieces : IOperation
    {
        #region IOperation Members
        IComponentAction breakAction;
        public string Name
        {
            get { return "Разбить профили на части"; }
        }

        public OperationGroup OperationGroup
        {
            get { return OperationGroup.ShprossOperation; }
        }

        public void Execute(ModelControl modelControl)
        {
            BreakComponentForm breakForm = new BreakComponentForm();
            if (breakForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                breakAction = new ActionBreakToPieces(breakForm.NumberOfPieces);
                foreach (IComponent innerComponent in modelControl.ModelContainer.AllInnerComponents)
                    if (innerComponent.Selected && innerComponent is Shpross)
                        breakAction.Action(innerComponent as Shpross);
            }
        }
        #endregion

        #region IOperation Members


        public System.Drawing.Image Thumbnail
        {
            get { return Resources.BreakToPieces; }
        }

        #endregion

        #region IOperation Members


        public bool CanUndo
        {
            get { return true; }
        }

        #endregion
    }
}
